
<?php include("header.php"); ?>

<script type="text/javascript">

function addRegion() {
    window.location.href = "<?php echo APPLICATION_URL;?>/region/form/";
}
</script>
	<div class="one_third">
		<div class="box_tool">
			<div class="box_head"><?php echo _LB_TOOLBOX; ?></div>

			<div class="box_content">
                <a id="auto_region_add" href="#" onclick="addRegion();">
					<?php echo _LB_ADD_REGION; ?>
				</a>
			</div>
		</div>
		<div class="spacer"></div>
		<div class="box_tool">
			<div class="box_head"><?php echo _LB_SEARCH; ?></div>
			<div class="box_content" id="filter_panel">
				<table>
				<form name='form_filter' method="post" action="">
				<tr>
					<td width="40%"><?php echo _LB_REGION_NAME; ?></td>
					<td width="60%">
						<input type="text" name="name" id="name" value="<?php echo $filter['name']; ?>" style="width: 180px;"/>
					</td>
				</tr>
                                <tr>
                                    <td width="40%"><?php echo _LB_COUNTRY; ?></td>
					<td width="60%">
						<select id="country" name="country" style="width: 180px;">
                                                    <option value=""><?php echo _LB_CHOOSE; ?></option>
                                                    <?php while($country->fetchNext()) { ?>
                                                       <option value="<?php echo $country->id; ?>" <?php if($country->id == $filter['country']) {?>selected="true"<?php }?>><?php echo $country->name; ?></option>
                                                    <?php } ?>
                                                </select>
					</td>
                                </tr>
				<tr>
					<td class="submit" colspan="2" style="padding-top:10px;">
						<a id="auto_region_search" class="tribullet" style="float:right" id="obj_search" href="#" onclick="document.form_filter.submit();"><?php echo _LB_FIND;?></a>
					</td>
				</tr>
				</form>
				</table>
			</div>
		</div>
	</div>

	<div class="two_third" style="height:1%">
		<div class="box_two_third">
			<div class="box_head"><?php echo _LB_REGION; ?></div>
			<div class="box_content">
			<?php if($region->countRows()) { ?>
					<?php while($region->fetchNext()) { ?>
					<div class="object" robotid="<?php echo $region->id; ?>">
						<div class="head">
							<div class="right remove_top">
								<a id="auto_region_edit_<?php echo $region->id;?>" href="<?php echo APPLICATION_URL;?>/region/form/<?php echo $region->id;?>">
									<img src="<?php echo IMG_URL;?><?php echo IMAGE_NAME_EDIT_SMALL;?>" title="<?php echo _LB_EDIT;?>" alt="<?php echo _LB_EDIT;?>"/>
								</a>
								<?php if($region->isDeleteAble($region->id)) {?>
									<a id="auto_region_delete_<?php echo $region->id;?>" onclick="return confirm('<?php echo _MSG_REGION_DELETE_CONFIRM;?>');" href="<?php echo APPLICATION_URL;?>/region/delete/<?php echo $region->id;?>">
										<img src="<?php echo IMG_URL;?><?php echo IMAGE_NAME_DELETE_SMALL?>" title="<?php echo _LB_DELETE;?>" alt="<?php echo _LB_DELETE;?>"/>
									</a>
							  	<?php } else { ?>
									<img class="small" src="<?php echo IMG_URL;?>delete_not_small.png"/>
								<?php } ?>
							</div>
							<b><?php echo $region->name;?></b>
						</div>
						<div class="content">
							<table border="0" cellpadding="3" cellspacing="0">
                                <tr>
									<td width="20%"><?php echo _LB_COUNTRY;?>&nbsp;:&nbsp;</td>
									<td>
										<?php echo $region->country_name; ?>
									</td>
								</tr>
								
							</table>
						</div>
					</div>
					<?php } ?>
			<?php } else { ?>
				<p><?php echo _MSG_NO_EXISTING_REGION;?></p>
			<?php } ?>
			</div>
		</div>
		
	</div>
<?php include("footer.php"); ?>
